<?php
/**
 * @orm tablename wb_basic_content_images
 */
class WbPageBasicContentImage extends  DomArObject {
	
	/**
	 * @orm has parent WbPageBasic inverse contentImages
	 * @var unknown_type
	 */
	public $page;
	/**
	 * @orm plugin DomArImage({autoRename=1r})
	 * @orm listener afterAdd afterAddImage
	 */
	public $image;
	/**
	 * @orm plugin DomArImage({autoRename=1r})
	 */
	public $icon;
	
	public function afterAddImage() {
		if( $this->image->exists() == false ) {
			return;
		}
		
		$config = Wb::getModuleConfig('WbPageBasic');
		
		$this->image->resize( $config['content']['imageWidth'], $config['content']['imageHeight']);
		$this->icon = $this->image->copy();
		$this->icon->resize($config['content']['iconWidth'], $config['content']['iconHeight'],false);
		$this->icon->cut($config['content']['iconWidth'], $config['content']['iconHeight']);
	}

}